package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsCategoryMapper;
import com.qf.pojo.DtsCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author mkr
 * @version V1.0
 * @Project java2203-mkr
 * @Package com.qf.service
 * @Description:
 * @Date 2022/6/21 15:39
 */
@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private DtsCategoryMapper categoryMapper;


    @Override
    public List<DtsCategory> selectCategorylist() {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("deleted", false);
        queryWrapper.eq("pid", 0);
        //查询并返回
        List<DtsCategory> list = categoryMapper.selectList(queryWrapper);
        return list;
    }

    @Override
    public List<DtsCategory> selectCategoryL2() {
        List<DtsCategory> list = categoryMapper.cateList();
        return list;
    }


    @Override
    public int add(DtsCategory category) {
        int count = categoryMapper.insert(category);
        return count;
    }

    @Override
    public int update(DtsCategory category) {
        int count = categoryMapper.updateById(category);
        return count;
    }

    @Override
    public int delete(DtsCategory category) {
        int count = categoryMapper.deleteById(category);
        return count;
    }
}

